package com.jiangyao.controller;


import com.jiangyao.common.ApiResult;
import com.jiangyao.model.dto.backend.ClassSemesterEditDTO;
import com.jiangyao.model.dto.backend.OrgClassSemesterDTO;
import com.jiangyao.model.vo.backend.OrgClassSemesterVO;
import com.jiangyao.service.ClassSemesterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 班级学期 前端控制器
 * </p>
 *
 * @author yangyongchuan
 * @since 2020-08-25
 */
@Api(tags = "班级学期")
@RestController
@RequestMapping("/classSemester")
public class ClassSemesterController extends BaseController {

	@Autowired
	private ClassSemesterService classSemesterService;

	/**
	 * 获取组织班级学期列表
	 *
	 * @param editDTO 请求DTO
	 * @return 结果
	 */
	@ApiOperation(value = "获取组织班级学期列表", notes = "必填字段：classId")
	@PostMapping("/list")
	public ApiResult<OrgClassSemesterVO> getOrgClassSemesterList(@Validated({ClassSemesterEditDTO.Edit.class}) @RequestBody ClassSemesterEditDTO editDTO) {
		return new ApiResult<>(classSemesterService.getOrgClassSemesterList(editDTO));
	}

	/**
	 * 编辑组织班级学期
	 *
	 * @param orgClassSemesterDTO 班级学期DTO
	 * @return 结果
	 */
	@ApiOperation(value = "编辑组织班级学期")
	@PostMapping("/chapter/update")
	public ApiResult<String> updateChapter(@Validated({OrgClassSemesterDTO.Edit.class}) @RequestBody OrgClassSemesterDTO orgClassSemesterDTO) {
		classSemesterService.updateOrgClassSemesterList(orgClassSemesterDTO);
		return new ApiResult<>();
	}

	/**
	 * 删除班级学期、班级学期课程
	 *
	 * @param editDTO 编辑DTO
	 * @return 结果
	 */
	@ApiOperation(value = "删除班级学期、班级学期课程", notes = "必填字段：classId；（semesterId、clsubId二选一）")
	@PostMapping("/chapter/delete")
	public ApiResult<String> deleteChapter(@Validated({ClassSemesterEditDTO.Delete.class}) @RequestBody ClassSemesterEditDTO editDTO) {
		classSemesterService.deleteClassSemester(editDTO);
		return new ApiResult<>();
	}

}

